#define DEBUG
#include <cstdio>

using namespace std;

const int maxm=100000, maxn=10000000;

int min(int a, int b) {
  return a<b ? a : b;
}

int main() {
#ifdef DEBUG
  freopen("0.in", "r", stdin);
  freopen("0.out", "w", stdout);
#endif
  
  static int p[maxm+1];
  int m, q;
  long long lcm=1;
  scanf("%d %d", &m, &q);
  for (int i=1; i<=m; i++) {
    scanf("%d", p+i);
    if (lcm<=maxn) {
      lcm = lcm*p[i];
    }
  }

  for (int i=1; i<=q; i++) {
    int n;
    scanf("%d", &n);
    if (n>=lcm) {
      printf("oo\n");
    } else {
      int ans=0;
      for (int minn=n; n>0; n=minn, ans++) {
	for (int j=m; j>0; j--) {
	  minn = min(minn, n-(n%p[j]));
	}
      }
      printf("%d\n", ans);
    }
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
